import sortedcontainers
class MyCalendar(object):

    def __init__(self):
        self.st = sortedcontainers.SortedList()
        self.len = 0

    def book(self, start, end):
        """
        :type start: int
        :type end: int
        :rtype: bool
        """
        index = self.st.bisect_right([start, end])
        if index < self.len and end > self.st[index][0]:
            return False
        if index > 0 and start < self.st[index - 1][1]:
            return False
        self.st.add([start, end])
        self.len += 1
        return True